package com.jsnu.xiaochi.service;

import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

@Service
public class RoleService {

    /**
     * 模拟根据用户id查询返回用户的所有角色，实际查询语句参考：
     * SELECT r.rval FROM role r, user_role ur
     * WHERE r.rid = ur.role_id AND ur.user_id = #{userId}
     * @param username
     * @return
     */
    public Set<String> getRolesByUsername(String username){
        Set<String> roles = new HashSet<>();
        if("admin".equals(username)){
            roles.add("admin");
        }else{
            roles.add("user");
        }
        return roles;
    }

}
